package com.exercise;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class StudentTest {
    public static void main(String[] args) {
        HashSet<Student> hm = new HashSet<Student>();
        Student st1 = new Student("张三","男",20);
        Student st2 = new Student("李四","女",21);
        Student st3 = new Student("张三","男",20);
        hm.add(st1);
        hm.add(st2);
        hm.add(st3);
        System.out.println("--------使用增强for遍历集合，获取每个Student对象，并打印属性值；--------");
        for (Student str: hm
             ) {
            System.out.println("学生姓名是" + str.getName() + "，性别是：" + str.getSex() + "；年龄是：" + str.getAge());
        }

    }
}
